import socket


def get_device_ip():
    # from https://cloud.tencent.com/developer/article/1505608
    socket_temp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    try:
        socket_temp.connect(('ek.hongen.com', 443))
        ip = socket_temp.getsockname()[0]
    finally:
        socket_temp.close()
    return ip


if __name__ == '__main__':
    print(get_device_ip())
